function main() {
    debugger
    const self = this;
    let formPartEle = this.$$element("form_part_13czab");

    let documentNo = formPartEle.$$getRenderElement().getDocumentNo();
    let isEdit = documentNo != null && documentNo !== "";

    let weiXinCode = self.$$("text_input_hdhysf").cValue;

    let pageRenderElement = this.$$root().$parent.$parent.$parent;
    if (formPartEle) {
        formPartEle.$$getRenderElement().onSave()
            .then((res) => {
                if (res) {
                    if (!isEdit) {
                        const verifyData = {
                            applyTypeId: 3,
                            objectId: res.result.documentNo,
                            applyHumanId: res.result.root_97ouh3.builtin_field_32zlo2,
                            applyReason: '移动端摊主申请'
                        };
                        let holderId = res.result.documentNo;
                        let telephone = res.result.root_97ouh3.text_input_9d0v82
                        addAuditRecord(verifyData).then(res=>{
                            insertHolderWeChatBind(weiXinCode, holderId, telephone);
                            self.$route.query.refresh = "1";
                            self.$router.back();
                        });


                    }
                    console.log("保存成功");
                } else {
                    console.log("保存失败");
                }
            })
    }

}

/**
 * 注册用户绑定用户微信
 * @param weiXinCode
 * @param holderId
 * @param telephone
 */
function  insertHolderWeChatBind(weiXinCode, holderId, telephone){
    const insertVerifyRecordSql = [
        ['weixin_code', `'${weiXinCode}'`],
        ['telephone', `'${telephone}'`],
        ['holder_id', `${holderId}`]
    ];

    const formattedFields = insertVerifyRecordSql.map(([key, value]) => {
        return `'${key}',${value}`;
    });

    const law_stall_holder_wechat_bind = "ds_tbl:t_6f6952e84b0b44feb82f564c3aa7951f";
    const insertSql = `INSERT('${law_stall_holder_wechat_bind}', [${formattedFields.join(',')}])`;
    console.log(insertSql);

    return new Promise((resolve, reject) => {
        api.EXEC_FORMULA(insertSql).then(res => {
            console.log(res);
            resolve(res);
        })
    })
}


/**
 * law_stall_organization_holder_verify
 * 申请类型,1：疏导点，2：摊位，3:摊主
 * object_id
 * @returns {Promise<unknown>}
 */
function addAuditRecord(verifyData) {

    const insertVerifyRecordSql = [
        ['apply_type_id', `'${verifyData.applyTypeId}'`],
        ['object_id', `'${verifyData.objectId}'`],
        ['apply_human_id', `${verifyData.applyHumanId}`],
        ['apply_human_name', 'USER_NAME()'],
        ['apply_reason', `'${verifyData.applyReason}'`],
        ['verify_state_id', '0'],
        ['apply_time', 'NOW()']
    ];

    const formattedFields = insertVerifyRecordSql.map(([key, value]) => {
        return `'${key}',${value}`;
    });

    const law_stall_organization_holder_verify = "ds_tbl:t_1aef92529dae4723ba36422faba4e546";
    const insertSql = `INSERT('${law_stall_organization_holder_verify}', [${formattedFields.join(',')}])`;
    console.log(insertSql);

    return new Promise((resolve, reject) => {
        api.EXEC_FORMULA(insertSql).then(res => {
            console.log(res);
            resolve(res);
        })
    })
}


